package com.tansun.ruledata.data.entity;


import java.util.Date;

import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tansun.easycare.core.persistence.BaseEntity;
import com.tansun.rule.utils.StringUtils;

/**
 * 数据集变量Entity
 *
 * @author lxs
 * @version 2017-02-24
 */
public class DeployDataparams extends BaseEntity {

    private static final long serialVersionUID = 1L;
    private String projectcode;        // 规则库编码
    private String datasetId;        // 关联数据集编号
    private String name;        // 变量名
    private String chzn;        // 中文名
    private String type;        // 数据类型
    private String domainId;        // 码值域ID
    private String domainType;        // 取值类型（集合、线性、离散、衍生）
    private String domainStr;        // 码值域显示
    private String mathStr;        // 衍生变量公式
    private String length;        // length
    private String defaultValue;        // 默认值
    private String isCollections;        // 是否集合
    private String isDerives;        // 是否衍生变量
    private String pattern;        // 日期格式
    private String isout;        // 是否输出
    private String paramDesc;        // 描述信息
    private String domain;        // domain
    private String collection;        // collection

    private String formatDomainStr;

    private String formatDefaultValue;
    
    private String className;//扩展字段


    public DeployDataparams() {
        super();
    }

    public DeployDataparams(String id) {
        super(id);
    }

    @Length(min = 0, max = 50, message = "规则库编码长度必须介于 0 和 50 之间")
    public String getProjectcode() {
        return projectcode;
    }

    public void setProjectcode(String projectcode) {
        this.projectcode = projectcode;
    }

    @Length(min = 0, max = 50, message = "关联数据集编号长度必须介于 0 和 50 之间")
    public String getDatasetId() {
        return datasetId;
    }

    public void setDatasetId(String datasetId) {
        this.datasetId = datasetId;
    }

    @Length(min = 0, max = 50, message = "变量名长度必须介于 0 和 50 之间")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Length(min = 0, max = 50, message = "中文名长度必须介于 0 和 50 之间")
    public String getChzn() {
        return chzn;
    }

    public void setChzn(String chzn) {
        this.chzn = chzn;
    }

    @Length(min = 0, max = 10, message = "数据类型长度必须介于 0 和 10 之间")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Length(min = 0, max = 10, message = "码值域ID长度必须介于 0 和 10 之间")
    public String getDomainId() {
        return domainId;
    }

    public void setDomainId(String domainId) {
        this.domainId = domainId;
    }

    @Length(min = 0, max = 20, message = "取值类型（集合、线性、离散、衍生）长度必须介于 0 和 20 之间")
    public String getDomainType() {
        return domainType;
    }

    public void setDomainType(String domainType) {
        this.domainType = domainType;
    }

    @Length(min = 0, max = 200, message = "码值域显示长度必须介于 0 和 200 之间")
    public String getDomainStr() {
        return domainStr;
    }

    public void setDomainStr(String domainStr) {
        this.domainStr = domainStr;
    }

    @Length(min = 0, max = 200, message = "衍生变量公式长度必须介于 0 和 200 之间")
    public String getMathStr() {
        return mathStr;
    }

    public void setMathStr(String mathStr) {
        this.mathStr = mathStr;
    }

    @Length(min = 0, max = 11, message = "length长度必须介于 0 和 11 之间")
    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    @Length(min = 0, max = 50, message = "默认值长度必须介于 0 和 50 之间")
    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    @Length(min = 0, max = 10, message = "是否集合长度必须介于 0 和 10 之间")
    public String getIsCollections() {
        return isCollections;
    }

    public void setIsCollections(String isCollections) {
        this.isCollections = isCollections;
    }

    @Length(min = 0, max = 10, message = "是否衍生变量长度必须介于 0 和 10 之间")
    public String getIsDerives() {
        return isDerives;
    }

    public void setIsDerives(String isDerives) {
        this.isDerives = isDerives;
    }

    @Length(min = 0, max = 20, message = "日期格式长度必须介于 0 和 20 之间")
    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    @Length(min = 0, max = 10, message = "是否输出长度必须介于 0 和 10 之间")
    public String getIsout() {
        return isout;
    }

    public void setIsout(String isout) {
        this.isout = isout;
    }

    @Length(min = 0, max = 200, message = "描述信息长度必须介于 0 和 200 之间")
    public String getParamDesc() {
        return paramDesc;
    }

    public void setParamDesc(String paramDesc) {
        this.paramDesc = paramDesc;
    }

    @Length(min = 0, max = 45, message = "domain长度必须介于 0 和 45 之间")
    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    @Length(min = 0, max = 50, message = "collection长度必须介于 0 和 50 之间")
    public String getCollection() {
        return collection;
    }

    public void setCollection(String collection) {
        this.collection = collection;
    }

    @JsonIgnore
    public String getFormatDomainStr() {
        if (StringUtils.isEmpty(domainStr)) {
            return domain;
        } else {
            return domainStr;
        }
    }


	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String getSql() {
		return "INSERT INTO rule_dataparams(id,projectcode,dataset_id,name,chzn,type,domain_id,domain_type,domain_str,math_str,length,default_value,is_collections,is_derives,pattern,isout,param_desc,create_date,domain,collection,data_version)"
				+ " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	}
	
	public String getExeSql() {
		return "INSERT INTO rule_exe_dataparams(id,projectcode,dataset_id,name,chzn,type,domain_id,domain_type,domain_str,math_str,length,default_value,is_collections,is_derives,pattern,isout,param_desc,create_date,domain,collection,data_version)"
				+ " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	}
	
	public Object[] getArgs(String timeStamp) {
		return new Object[] {this.id,this.projectcode,this.datasetId,this.name,this.chzn,this.type, this.domainId,this.domainType,this.domainStr,this.mathStr,this.length,this.defaultValue,this.isCollections,this.isDerives,this.pattern,this.isout,this.paramDesc,new Date(),this.domain,this.collection,timeStamp};
	}
}